Build a Temperature, Humidity, and Dew Point Data Logger with ESP32

In this project, we will build a temperature, humidity, and dew point data logger with ESP32. This system will show the current time on a 20×4 LCD along with temperature, humidity, and dew point and periodically log the data on an SD card. In the design, an ESP32 microcontroller is used, together with a DS3231 RTC module for correct time representation and a CHT8305 sensor for temperature and humidity readings.

The temperature, humidity, and dew point data logger with ESP32 is a versatile project useful in applications such as environmental monitoring, greenhouse automation, and weather tracking.

Components Required for Build a Temperature, Humidity, and Dew Point Data Logger with ESP32:

  1. ESP32 Development Board
  2. 20×4 I2C LCD Display
  3. DS3231 RTC Module
  4. SD Card Module
  5. CHT8305 Temperature and Humidity Sensor

Circuit Diagram

To build a temperature, humidity, and dew point data logger with ESP32, you will need to connect the components to the ESP32 as follows:

  • LCD (I2C):
    • SDA (LCD) to GPIO 21 (ESP32)
    • SCL (LCD) to GPIO 22 (ESP32)
  • RTC Module (DS3231):
    • SDA (RTC) to GPIO 21 (ESP32)
    • SCL (RTC) to GPIO 22 (ESP32)
  • SD Card Module:
    • CS (SD) to GPIO 5 (ESP32)
    • MOSI to GPIO 23
    • MISO to GPIO 19
    • SCK to GPIO 18
  • CHT8305 Sensor:
    • SDA (CHT8305) to GPIO 21 (ESP32)
    • SCL (CHT8305) to GPIO 22 (ESP32)

Circuit Diagram of Temperature Humidity and Dew Point Data Logger with ESP32

Description of System:

The current time is read from the DS3231 RTC, and the temperature and humidity data are read from the CHT8305 sensor. Then, it would use the Magnus formula to calculate the dew point. It displays it on the 20×4 LCD while logging every 5 minutes into a text file in an SD card inside the device. An ESP32-based Temperature and Humidity Data Logger is best suited for acquiring time-stamped environmental data.

Interfacing the CHT8305 Temperature and Humidity Sensor

The CHT8305 sensor is an I2C-based sensor designed for temperature and humidity measurement. It is one of the significant elements comprising an ESP32 data logger. For an in-depth tutorial regarding interfacing the CHT8305 sensor with ESP32, you can refer to this tutorial. Interfacing the CHT8305 Sensor with ESP32: Real-Time Temperature and Humidity Display

Using the DS3231 RTC for Timekeeping

The DS3231 RTC module is a key component in this project, as it gives the data logged a timestamp. If you want to know how to set up the DS3231 RTC with the ESP32, this is the guide you would want to look at. How to Set Up a Real-Time Clock (RTC) with ESP32 and DS3231 Using NTP Time Synchronization

Interfacing the I2C LCD with ESP32

In our circuitry, we will use a 20×4 I2C LCD to display the current date, time, temperature, humidity, and dew point. An article on interfacing I2C LCDs with ESP32 and other microcontrollers may be found here. How to Interface Multiple I2C LCD to Arduino

SD Card Logging with ESP32

It logs the data to the SD card module. The temperature, humidity, and dew point data logger with ESP32 writes each reading along with its timestamp in a text file after every 5 minutes. Learn more about interfacing of SD card with ESP32 here in this tutorial. SD Card Interfacing with ESP32

prototype of temperature humidity and dew point data logger with esp32

Figure 2: Author Prototype of Temperature Humidity and Dew Point Data Logger with ESP32

Software Code Walkthrough

In this project, the ESP32 handles reading from the sensor, formatting of the data, display on the LCD, and logging to the SD card. Here’s a complete code for a temperature, humidity, and dew point data logger with ESP32:

 

Dew Point Calculation:

Coming to the calculation of dew in the ESP32-based temperature, humidity, and dew point data logger, the Magnus formula relates both the temperature and humidity in calculating the dew point: 

const float a = 17.27, b = 237.7;

float alpha = ((a * temp) / (b + temp)) + log(hum / 100.0);

return (b * alpha) / (a – alpha);

data saved in sd card

Figure 3: Data Sample Saved in SD Card

This tutorial is going to take you through building a temperature, humidity, and dew point data logger using ESP32. The system will be displaying real-time environmental data on an LCD while logging that data on an SD card for analysis later. Also, thanks to the DS3231 RTC module, accurate timestamps enable one to track the changes in environmental parameters over time.

PCB Diagram:

Download the PCB solder side and component side from the link provided below.

Download PCB

For more elaborative details and tutorials on the interfacing of the components used in this project, refer to the link.

 

Leave a Comment